
Ext.define('PW.view.papeis.MeusPapeis' ,{
    extend: 'Ext.grid.Panel',
    alias : 'widget.meusPapeis',
    title : 'Meus Papeis',
    id: 'meusPapeis',
    columns : [{
        header: 'Sigla', 
        dataIndex: 'sigla',
        flex: 1
    }, {
        header: 'Nome',
        dataIndex: 'nome',
        flex: 3
    }, {
        header: 'Cota\u00e7\u00e3o', 
        dataIndex: 'cotacao',
        renderer: 'usMoney',
        flex: 1
    }, {
        header: 'Total',
        align: 'right',
        dataIndex: 'quantidade',
        flex: 1
    }, {
        header: 'Lucro (%)',
        dataIndex: 'lucro',
        align: 'center',
        flex: 2
    }, {
        header: 'Quantia',
        dataIndex: 'qtde_venda',
        align: 'right',
        flex: 1,
        editor: {
            xtype: 'numberfield',
            minValue: 0,
            align: 'right',
            maxValue: 100000000
        }
    }, {
    	header: 'Vender',
		xtype : 'actioncolumn',
		cls: 'venderAcoes',
		width : 50,
		flex: 1,
		items : [ {
			icon : 'ext-4.1.1/resources/themes/images/money-add.png',
			tooltip : 'Vender',
			handler: function(view, rowIndex, colIndex, item, e) {
				var eOpts = {
					view: view,
					rowIndex: rowIndex,
					colIndex: colIndex,
					e: e,
					type: 'vender'
				};
                this.fireEvent('itemclick', this, eOpts);
            }
		}]
	}, {
		flex: 10
	}],
    selType: 'cellmodel',
    plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
        clicksToEdit: 1
    })],
    viewConfig : {
    	getRowClass: function(record, rowIndex, rowParams, store){
	    	if(record.data.vl_estrategia < 2){
	    		return 'rowGreen';
	    	} else if(record.data.vl_estrategia > 8){
	    		return 'rowRed';
	    	} else {
	    		return 'rowBlack';
	    	}
    	}
    },
    initComponent : function() {
		this.store = Ext.data.StoreManager.lookup('PW.store.MeusPapeis');
		this.store.load();
		
		this.callParent(arguments);
	}
});
